package com.example.pojo;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private String message;
    private Integer code;
    private T data;

    public static <T> Result<T> success() {
        Result result = new Result();
        result.setCode(0);
        return result;
    }

    public static <T> Result<T> success(T data) {
        Result result = new Result();
        result.setCode(0);
        result.setData(data);
        return result;
    }
    public static <T> Result<T> error(Integer code, String message) {
        Result result = new Result();
        result.setCode(code);
        result.setMessage(message);
        return result;
    }
    public static <T> Result<T> error(String message) {
        return error(1, message);
    }
}
